package com.itnoob.controller;

import cn.hutool.extra.spring.SpringUtil;
import com.itnoob.factory.PaymentFactory;
import com.itnoob.pay.Payment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author zhoujun
 * @date 2025/3/19 21:12
 */
@RestController
@RequestMapping("/factorybeanstrategy")
public class PaymentController {

    @Autowired
    private PaymentFactory paymentFactory;

    @RequestMapping("/pay")
    public String pay(@RequestParam("amount") BigDecimal amount, @RequestParam("type") String type) {
        Payment payment = paymentFactory.getPayment(type);
        payment.pay(amount);
        return "您已经使用" + type + "支付了" + amount + "元";

    }
}
